<!--#include file="Admin/Includes/constants.asp"-->
<!--#include file="Admin/Includes/validate.asp"-->
<%
SSLMode = 1
'------------Authentication----------------------------
Verify
'------------Authentication----------------------------
MakeSSL 1
Dim Action, AlbumName, AlbumType, AlbumID , fName, strAction
Dim i, aData, nRows, hasData, aData2, nRows2, hasData2
Dim strMes, result
Dim isupd, sAdd, sUpdate, altBg, altStyle
Dim referer, FavoriteID

sAdd = "Tạo album"
sUpdate = "Cập nhật album"

If request("act") = "Tạo album" Then
	Action = "add"
ElseIf request("act") = "Cập nhật album" Then
	Action = "upd"
Else 
	Action = request("act")
End If

'passing from Add Pic page
if request.Form("r") <> "" then 
	referer = request.Form("r") 	
Else
	referer = Request.ServerVariables("HTTP_REFERER")	
End If
If request.Form("fid") > "" Then
	FavoriteID = request.Form("fid") 
Else
	FavoriteID = request.Querystring("fid") 
End If
'/passing from Add Pic page

	fName = request("fn")	'use for filter
	AlbumName = getData("rqAlbumName")		'ten album
	
	If getData("rqAlbumType") <> "" Then
		AlbumType = getData("rqAlbumType")	'Loại Album
	Else
		AlbumType=0
	End If
	
	If getData("AlbumID") <> "" Then
		AlbumID = getData("AlbumID")
	Else
		AlbumID=0
	End If
	
	if AlbumID = "" or Action = "add" then  
		AlbumID = 0
	elseif Action <>"del" then
		isupd = true
	end if 
	
	strSQL = "{CALL a_album_sel ('"& Action & "',N'" & fName & "',"&AlbumID&",N'"&AlbumName&"',"&AlbumType&",'"&CookieID&"')}"	
	'response.write strsql
	exec(strsql)
	result = RS(0)
	if result = 0 then
		strMes = "Đã tạo tên album!"	
		AlbumID = RS(1)
		isupd = true
	elseif result = 1 then
		strMes = "Đã cập nhật tên album!"		
	elseif result = 2 then
		strMes = "Đã xóa tên album!"					
		AlbumID = 0	
	elseif result = -1 then
		if AlbumID <> 0 then
			strMes ="Không cập nhật tên album được vì tên <strong>"&AlbumName&"</strong> đã có!"
		else
			strMes ="Tên <strong>"&AlbumName&"</strong> đã có. Xin vui lòng chọn một tên khác!"			
		end if
	end if
	
	'get header of Brand
	Set RS = RS.NextRecordSet
	IF not RS.EOF then
		aData = RS.getrows
		nRows = Ubound(aData,2)
		hasData = true
	end if
	
	'get detail Brand
	Set RS = RS.NextRecordSet
	IF not RS.EOF then		
		AlbumName = RS(0)
		AlbumType = RS(1)
	end if
	
	'get list Brand has fiter
	Set RS = RS.NextRecordSet
	IF not RS.EOF then
		if RS(0) <> "0" then
		aData2 = RS.getrows
		nRows2 = Ubound(aData2,2)
		hasData2 = true
		end if
	end if


'Close connection
CloseCon
	
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<head>
	<Meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Quản lý album</title>
	<Meta http-equiv=" content-language" content ="vi">
	<Meta name="Robots" content="noindex,nofollow">
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> 
	<link rel="icon" href="favicon.ico" type="image/x-icon"> 
	<link rel="STYLESHEET" type="text/css" href="system/styles.css">

<script language="javascript" src="Admin/javascripts/validateVN.js"></script>
<script language="javascript" src="Admin/javascripts/handler.js"></script>
</head>
<body  onLoad="document.frm.rqAlbumType.focus()">
<div id="container">
<div id="bt2"><img src="hinh-thoi-trang/bg_top.gif" width="1049" height="20"></div>
<div id="tp">
<table border="0" cellpadding="0" cellspacing="0" width="990" align="center">	
	<!--#include file="system/top.asp" -->
	<tr bgcolor="#6b5a60">
		<td width="160" style="height:1px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td>
		<td width="522" valign="top" rowspan="2">
		
	<!--body content-->		
		<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#B6A8AD">	
			<tr><td colspan="1" style="padding-left:13px;padding-top:3px;"><img src="hinh-thoi-trang/quan-ly-album-hp.gif" width="400" height="40"></td></tr>				
			<tr bgcolor="#000000"><td colspan="9"><img src="hinh-thoi-trang/de_clear.gif" width="1" height="1" border="0"></td></tr>
			<tr bgcolor="#E5DFE1"><td colspan="9"><img src="hinh-thoi-trang/de_clear.gif" width="1" height="1" border="0"></td></tr>
			<tr>	
			<td valign="top" height=400 >
				<table cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF" width=100%%>
				<% if strMes <> "" then%>
				<tr><td colspan="2" class="lsTitle" style="color:#8D0045;padding:10 0 10 12; background-color:#F7F6BD"><%=strMes%></td></tr>
				<%end if%>
				<tr>
					<td style="padding-left:9px;padding-top:15px" height="100%" valign=top>		
						<table border="0" cellpadding="3" cellspacing="0" width="310">
							
							<form name ="frm" action="<%=encodeURL("user_favimg_albums.asp")%>" method="post" onSubmit="return isValid(this)">
							<input type="hidden" name ="AlbumID" value="<%=AlbumID%>">
							<input type="hidden" name ="fn" value="<%=fName%>">		
							<input type="hidden" name="fid" value="<%= FavoriteID %>">
							<input type="hidden" name="r" value="<%= referer %>">							
							<tr>
								<td class="paging" nowrap>Tên Album</td>
								<td><input type="text" id="Tên Album" name="rqAlbumName" value="<%=AlbumName%>" style="width:208px" class="txtInput"></td>
							</tr>
							<tr>
								<td class="paging" nowrap>Loại Album</td>
								<td><select name="rqAlbumType" id="Loại Album" style="width:208px" class="txtInput">									
									<option value="0" <% If AlbumType=0 Then response.Write("selected") End If%>>Đồ tôi thích</option>
									<option value="1" <% If AlbumType=1 Then response.Write("selected") End If%>>Đồ tôi muốn mua</option>										
								</select>
								</td>
							</tr>															
							<tr>
								<td>&nbsp;</td>
								<td><input type="submit" name="act" value="<%=sAdd%>" class="btnGo"><%if strcomp(AlbumID, 0) <> 0 then %><input type="submit" name="act" value="<%=sUpdate%>" class="btnGo" style="margin-left:3px;"><%end if%></td>
							</tr>
							
							</form>				
						</table>
					</td>
				</tr>
				<tr><td><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="15" border="0"></td></tr>
				<tr><td bgcolor="#B6A8AD"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>		
				<!--LIST HEADER-->
				<tr>
					<td style="padding:0 10 0 10">
						<% if hasData then %>
							<a href="user_favimg_albums.asp?ckid=<%=ckid%>"  class="NavL1" style="color:#333333;">All</a>&nbsp;&nbsp;						
						<%for i = 0 to nRows%>
							<a href="user_favimg_albums.asp?fn=<%=Server.URLEncode(aData(0,i))%>&ckid=<%=ckid%>" class="NavL1" style="color:#333333;" <%if fName = aData(0,i) then %> style="font-weight:bold" <%end if%> ><%=UCase(aData(0,i))%></a>&nbsp;&nbsp;
						<%next
						end if%>
					</td>
				</tr>										
				<!--LIST HEADER-->	
				<tr><td bgcolor="#B6A8AD"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>	
							
				<% if hasData2 and hasData then %>
				<tr>
					<td>
					<table border="0" cellpadding="0" cellspacing="0" width="100%">	
						<tr>
						<td style="padding:10 10 10 10">
							<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#F7F6BD" style="border-style:solid; border-width:1px; border-color:#8F996E; padding-left:6px;">
								<tr bgcolor="#8F996E">
									<td height="20" class="NavL1" style="color:#ffffff; padding-left:5px">Tên Album</td>
									<td class="NavL1" style="color:#ffffff; padding-left:5px">Loại Album</td>										
									<td class="NavL1" style="color:#ffffff; padding-left:5px">Thao Tác</td>
								</tr>
								<%
								if hasData2 then 										
								for i= 0 to nRows2
									if cint(aData2(0,i)) = cint(AlbumID)then
										altBg =""
									elseif (i +1) mod 2 = 0 then
										altBg ="bgcolor='#FFFFFF'"
										altStyle ="style='font-size:10px;font-weight:bold;'"
									else
										altBg = ""
										altStyle=""
									end if
								%>
								<tr <%=altBg%>>
									<td height="20" class="lsTitle" <%=altStyle%>><%=aData2(1,i)%> <i style="color:#999999;font-weight:normal;font-size:10px">(<%=aData2(3,i)%>)</i></td>
									<td height="20" class="paging"><%If aData2(2,i)=False Then response.Write("Đồ tôi thích") Else response.Write("Đồ tôi muốn mua") End If%></td>										
									<td width="80"><a href="user_favimg_albums.asp?AlbumID=<%=aData2(0,i)%>&fn=<%=fName%>&ckid=<%=ckid%>"><img src="../hinh-thoi-trang/ico_edit.gif" alt="Cập nhật album" width="12" height="12" border="0"></a>&nbsp;&nbsp;<a href="user_favimg_albums.asp?AlbumID=<%=aData2(0,i)%>&act=del&ckid=<%=ckid%>&fn=<%=fName%>" onclick="return confirmDelete('LƯU Ý: Tất cả các hình trong album này sẽ bị xóa, bạn có chắc không?');"><img src="../hinh-thoi-trang/ico_delete.gif" alt="Xóa album" border="0"></a></td>
								</tr>
								<%
								Next
								end if%>
							</table>						  
						  </td>
						  </tr>							 
					</table>							  	
					</td>
			  </tr>	
			 <% Else %>
				<tr bgcolor="#F7F6BD">
					<td style="padding:20 10 10 13" valign="top" class="lsTitle">Bạn chưa tạo album hình yêu thích nào!</td>
				</tr>							
			  <%end if%>
		  </table>		  
		  </td>
		  </tr>
		  
		</table>
	<!--/body content-->
		</td>
		<td width="308" style="height:1px"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td>
	</tr>
	<!--main body-->
	<tr bgcolor="#ffffff">
		<td bgcolor="#000000" width="160" valign="top">
			<!--#include file="system/left_user.asp" -->
		</td>
		<!--missing 1 TD because of Rowspan-->
		<td bgcolor="#614B00" width="308" valign="top">
			<table border="0" cellpadding="0" cellspacing="0" width="308" align="right">
				<tr bgcolor="#000000"><td colspan="2"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
				<form action="listing.asp?ckid=<%=ckid%>" method="post">
				<tr bgcolor="#8D0045">
					<td width="154" valign="top" height="33" ><input type="text" name="search" value="Tìm kiếm" size="22" class="txtSearch"></td>
					<td width="154" valign="top" style="padding-top:7px;padding-left:3px;"><input type="submit" name="go" value="TÌM" class="btnGo"></td>
				</tr>
				</form>
				<tr bgcolor="#000000"><td colspan="2"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
				<!--Ads Starts-->
				<tr><td align="center" colspan="2"><img src="hinh-quang-cao/neimanmarcus350x250.jpg" alt="" width="300" height="250" border="0"></td></tr>
				<!--Ads Ends-->
			</table>
		</td>
	</tr>
	<!--/main body-->
	<!--bottom-->
	<!--#include file="system/bottom.asp" -->
</table>
</div>
<div id="bt2"><img src="hinh-thoi-trang/bg_bottom.gif" width="1049" height="20"></div>
</div>
</body>
</html>
